
public class UserController {
    private UserService userService = new UserService();

    // 用户登录
    public void login(String username, String password) {
        User user = userService.queryByUsername(username);
        if (user != null && user.getPassword().equals(password)) {
            System.out.println("Login successful!");
        } else {
            System.out.println("Login failed!");
        }
    }

    // 用户注册
    public void reg(User user) {
        userService.add(user);
        System.out.println("Registration successful!");
    }
}